Skip to contentSkip to conversation

Change in openvpn[master]: Fix check_session_buf_not_used using wrong index

Openvpn-devel In review plaisthos (Code Review) 3 participants 6 messages Nov 22, 2023 – Dec 2, 2023 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1700694723000.Ia3d5b4946138df322ebcd9e9e77d04328dacbc5d@...2715...

#1 lore raw

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/459?usp=email

to review the following change.

Change subject: Fix check_session_buf_not_used using wrong index
......................................................................

Fix check_session_buf_not_used using wrong index

The inner loop used i instead of j when iterating through the buffers. Since i is always between 0 and 2 and ks->send_reliable->size is (when it is defined) always 6 (TLS_RELIABLE_N_SEND_BUFFERS) this does not cause an index of out bounds. So while the check is not doing anything really useful with i instead of j, it at least is not crashing or anything similar.

Noticed-By Jon Williams (braindead-bf) on Github issue #449
Change-Id Ia3d5b4946138df322ebcd9e9e77d04328dacbc5d

---
M src/openvpn/ssl.c

1 file changed, 1 insertion(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/59/459/1

src/openvpn/ssl.c +1 -1
index 400230c..b5d24b5 100644
@@ -3207,7 +3207,7 @@
 
         for (int j = 0; j < ks->send_reliable->size; j++)
         {
-            if (ks->send_reliable->array[i].buf.data == dataptr)
+            if (ks->send_reliable->array[j].buf.data == dataptr)
             {
                 msg(M_INFO, "Warning buffer of freed TLS session is still in"
                     " use (session->key[%d].send_reliable->array[%d])",

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/459?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia3d5b4946138df322ebcd9e9e77d04328dacbc5d
Gerrit-Change-Number: 459
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/459?usp=email )

Change subject: Fix check_session_buf_not_used using wrong index
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/459?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia3d5b4946138df322ebcd9e9e77d04328dacbc5d
Gerrit-Change-Number: 459
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Tue, 28 Nov 2023 10:43:23 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH 1/1 Fix check_session_buf_not_used using wrong index

In reply to a message not in the archive

From: Arne Schwabe <[email protected]...>

The inner loop used i instead of j when iterating through the buffers. Since i is always between 0 and 2 and ks->send_reliable->size is (when it is defined) always 6 (TLS_RELIABLE_N_SEND_BUFFERS) this does not cause an index of out bounds. So while the check is not doing anything really useful with i instead of j, it at least is not crashing or anything similar.

Noticed-By Jon Williams (braindead-bf) on Github issue #449
Change-Id Ia3d5b4946138df322ebcd9e9e77d04328dacbc5d

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/459
This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>

src/openvpn/ssl.c +1 -1
index 400230c..b5d24b5 100644
@@ -3207,7 +3207,7 @@
 
         for (int j = 0; j < ks->send_reliable->size; j++)
         {
-            if (ks->send_reliable->array[i].buf.data == dataptr)
+            if (ks->send_reliable->array[j].buf.data == dataptr)
             {
                 msg(M_INFO, "Warning buffer of freed TLS session is still in"
                     " use (session->key[%d].send_reliable->array[%d])",
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix check_session_buf_not_used using wrong index

Indeed, that function seems to be slightly cursed... and this is the right fix. For this bug.

Tested more thoroughly :-) (full server test runs + GHA).

Your patch has been applied to the master and release/2.6 branch.

commit 59551b93cdb55397d63b2fe58ad99612821c0faf (master) commit 5def8d935335619b16452b56b332d06f4d621d75 (release/2.6)

Author: Arne Schwabe
Date:   Tue Nov 28 11:43:59 2023 +0100
     Fix check_session_buf_not_used using wrong index

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Frank Lichtenheld <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg27576.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/459?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld

Change subject: Fix check_session_buf_not_used using wrong index
......................................................................

Fix check_session_buf_not_used using wrong index

The inner loop used i instead of j when iterating through the buffers.

Since i is always between 0 and 2 and ks->send_reliable->size is (when it is defined) always 6 (TLS_RELIABLE_N_SEND_BUFFERS) this does not cause an index of out bounds. So while the check was not doing anything really useful with i instead of j, at least it was not crashing or anything similar.

Noticed-By Jon Williams (braindead-bf) on Github issue #449
Change-Id Ia3d5b4946138df322ebcd9e9e77d04328dacbc5d

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27576.html

---
M src/openvpn/ssl.c

1 file changed, 1 insertion(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/59/459/2

src/openvpn/ssl.c +1 -1
index 400230c..b5d24b5 100644
@@ -3207,7 +3207,7 @@
 
         for (int j = 0; j < ks->send_reliable->size; j++)
         {
-            if (ks->send_reliable->array[i].buf.data == dataptr)
+            if (ks->send_reliable->array[j].buf.data == dataptr)
             {
                 msg(M_INFO, "Warning buffer of freed TLS session is still in"
                     " use (session->key[%d].send_reliable->array[%d])",

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/459?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia3d5b4946138df322ebcd9e9e77d04328dacbc5d
Gerrit-Change-Number: 459
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/459?usp=email )

Change subject: Fix check_session_buf_not_used using wrong index
......................................................................

Fix check_session_buf_not_used using wrong index

The inner loop used i instead of j when iterating through the buffers.

Since i is always between 0 and 2 and ks->send_reliable->size is (when it is defined) always 6 (TLS_RELIABLE_N_SEND_BUFFERS) this does not cause an index of out bounds. So while the check was not doing anything really useful with i instead of j, at least it was not crashing or anything similar.

Noticed-By Jon Williams (braindead-bf) on Github issue #449
Change-Id Ia3d5b4946138df322ebcd9e9e77d04328dacbc5d

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27576.html

---
M src/openvpn/ssl.c

1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/ssl.c +1 -1
index 400230c..b5d24b5 100644
@@ -3207,7 +3207,7 @@
 
         for (int j = 0; j < ks->send_reliable->size; j++)
         {
-            if (ks->send_reliable->array[i].buf.data == dataptr)
+            if (ks->send_reliable->array[j].buf.data == dataptr)
             {
                 msg(M_INFO, "Warning buffer of freed TLS session is still in"
                     " use (session->key[%d].send_reliable->array[%d])",

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/459?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia3d5b4946138df322ebcd9e9e77d04328dacbc5d
Gerrit-Change-Number: 459
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged